package com.example.biketask.service.impl;

import com.example.biketask.dao.Opt1Mapper;
import com.example.biketask.dao.OptUserMapper;
import com.example.biketask.pojo.UserOperation;
import com.example.biketask.pojo.ClickOperation;
import com.example.biketask.service.TypeOperationService;
import com.example.biketask.util.DataStyle;
import com.example.biketask.util.IPUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TypeOperationServiceImpl implements TypeOperationService {


    @Autowired private Opt1Mapper opt1Mapper;

    @Autowired private OptUserMapper optUserMapper;

    //@Override
    public void add_click_option(int optType, ClickOperation clickOperation) {

        //创建UserOperation
        UserOperation userOperation = new UserOperation();

        //获取用户ip地址
        String ipAddr = IPUtils.getIpAddr();

        //获取当前时间
        DataStyle dataStyle = new DataStyle();

        //赋值UserOperation
        userOperation.setOptType(optType);
        userOperation.setUserIp(ipAddr);
        userOperation.setCreateTime(dataStyle.DataStyle());


        optUserMapper.userOperation(userOperation);

        clickOperation.setOptId(userOperation.getId());

        opt1Mapper.insert_bt_02(clickOperation);

    }

}
